package util {
	import flare.animate.TransitionEvent;
	import flare.animate.Transitioner;
	import flare.display.TextSprite;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.filters.DropShadowFilter;
	import flash.text.TextFormat;
	
	import org.aswing.AsWingManager;
	import org.aswing.JPanel;
	import org.aswing.JScrollPane;

	[SWF(frameRate="30")]
	public class TextMarquee extends TextSprite {
		private var text_:Array = [];
		
//		public var panel:JScrollPane;
		private var t_:Transitioner = new Transitioner(2);
		public function TextMarquee(text:Array) {
			var fmt:TextFormat = new TextFormat("Arial", 14);
			fmt.leftMargin = 2;
			fmt.rightMargin = 2;
			super("", fmt);
			
			text_ = text;
			t_.addEventListener(TransitionEvent.END, function(event:Event):void {
				update();
//				dirty();
				t_.play();
			});
			setUpFormat();
			
		}
		private function setUpFormat():void {
//			new TextFormat

			
			var tip:TextSprite = this;
//			tip = new TextSprite("", fmt);
			tip.textField.border = true;
			tip.textField.borderColor = 0;
//			tip.textField.background = true;
//			tip.textField.backgroundColor = 0xf5f5cc;
			tip.textField.multiline = true;
//			tip.filters = [new DropShadowFilter(4,45,0,0.5)];
//new DropShadowFilter
		}
		public function marquee():void {
			this.text = joinStrings();
			dirty();
			t_.play();
		}
		private function update():void {
			cyclicShift();
			var text:String = joinStrings();
//			t_.$(this).text = text;
			this.text = text;
			dirty();
			// trace('TextMarquee >' + text + ' ' + this.text);
		}
		public function joinStrings():String {
			return text_.join("\n");
		}
		public function cyclicShift():void {
			var t:String = text_.shift();
			text_.push(t);
		}
	}
}